package cn.pfz.Service.impl;

import cn.pfz.Service.IConsumptionService;
import cn.pfz.domain.Consumption;
import cn.pfz.domain.ConsumptionItemKey;
import cn.pfz.domain.ConsumptionKey;
import cn.pfz.mapper.ConsumptionMapper;
import cn.pfz.query.ConsumptionQueryObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * @Author: 普发忠
 * @Date: 2021/09/14/14:45
 */
@Service
public class IConsumptionServiceimpl implements IConsumptionService {
    
    @Autowired
    private ConsumptionMapper consumptionMapper;
    
    @Override
    public int deleteByPrimaryKey(Long id) {
        return consumptionMapper.deleteByPrimaryKey(new ConsumptionKey(id));
    }
    
    @Override
    public int insert(Consumption record) {
        return consumptionMapper.insert(record);
    }
    
    @Override
    public Consumption selectByPrimaryKey(Long id) {
        return consumptionMapper.selectByPrimaryKey(new ConsumptionKey(id));
    }
    
    @Override
    public List<Consumption> selectAll() {
        return consumptionMapper.selectAll();
    }
    
    @Override
    public int updateByPrimaryKey(Consumption record) {
        return consumptionMapper.updateByPrimaryKey(record);
    }
    
    @Override
    public PageInfo<Consumption> list(ConsumptionQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(),"id asc");
        List<Consumption> consumptions = consumptionMapper.selectForList(qo);
        PageInfo<Consumption> objectPageInfo = new PageInfo(consumptions);
        return objectPageInfo;
    }
    
    @Override
    public Consumption selectByCno(String cno) {
        return consumptionMapper.selectByCno(cno);
    }
}
